package com.wc.user.controller;

import com.wc.base.vo.BaseResponse;
import com.wc.user.bean.UserEntity;
import com.wc.user.service.CSDNService;
import com.wc.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:用户接口
 * @Author: wuchao
 * @Date: 2018/8/3
 */
@Api(value = "用户接口")
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @Autowired
    private CSDNService cSDNService;
    private static String UPLOADED_FOLDER = "E://temp//";
    @ApiOperation(value = "添加用户")
    @PostMapping("/")
    public BaseResponse<String> user(@RequestBody UserEntity user){
        UserEntity userEntity = userService.save(user);
        return new BaseResponse<>();
    }
    @ApiOperation(value = "删除用户")
    @DeleteMapping("/{userId}")
    public BaseResponse<String> deleteUser(@PathVariable Integer userId){
        return new BaseResponse<>();
    }
    @ApiOperation(value = "修改用户")
    @PutMapping("/{userId}")
    public BaseResponse<String> updateUser(@RequestBody UserEntity user,@PathVariable Integer userId){
        UserEntity userEntity = userService.save(user);
        return new BaseResponse<>();
    }
    @ApiOperation(value = "查询用户")
    @GetMapping("/{userId}")
    public BaseResponse<UserEntity> queryUser(@PathVariable Integer userId){
        UserEntity user = userService.findById(userId);
        return new BaseResponse<>(user);
    }


}
